package com.ph.shopping.common.core.other.bankcard.util;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSONObject;
import com.ph.shopping.common.core.other.bankcard.request.CheckBankCardData;
import com.ph.shopping.common.core.other.bankcard.response.CheckBankResponse;
import com.ph.shopping.common.util.http.UrlRequestUtil;
/**
 * 
 * @ClassName:  CheckBankCardUtil   
 * @Description:校验银行卡信息工具类  
 * @author: puhui
 * @date:   2017年4月1日 上午9:48:09     
 * @Copyright: 2017 www.tydic.com Inc. All rights reserved.
 */
public class CheckBankCardUtil {
	
	private static final Logger log = LoggerFactory.getLogger(CheckBankCardUtil.class);
	/**
	 * 
	 * @Title: bankCardCheck   
	 * @Description: 认证身份证   
	 * @param: @param request
	 * @param: @return      
	 * @return: CheckResponse      
	 * @throws
	 */
	public static CheckBankResponse bankCardCheck(CheckBankCardData request){
		CheckBankResponse response = null;
		if(request != null){
			StringBuilder sbud = new StringBuilder();
			sbud.append("name=").append(request.getName())
			.append("&cardNum=").append(request.getCardNum())
			.append("&bankCardNo=").append(request.getBankCardNo());
			String result = UrlRequestUtil.sendPost(request.getCheckUrl(), sbud.toString());
			if(log.isDebugEnabled()){
				log.debug("银行卡校验返回值 result ： " + result);
			}
			if(StringUtils.isNotBlank(result)){
				response = JSONObject.parseObject(result, CheckBankResponse.class);
			}
		}
		return response;
	}
}
